//角色管理相关的接口函数
//导入二次封装axios
import request from "@/utils/request";
import type { GetRoleListApiParams, GetRoleListRes } from "./models/roleModel";

//枚举接口地址
enum Api {
  getRoleListUrl = "/admin/acl/role",
  addRoleUrl = "/admin/acl/role/save",
}

/**
 * 获取角色列表的接口函数
 * @param GetRoleListApiParams
 * @returns GetRoleListRes
 */
export const getRoleListApi = ({
  page,
  limit,
  roleName,
}: GetRoleListApiParams) => {
  return request.get<any, GetRoleListRes>(
    `${Api.getRoleListUrl}/${page}/${limit}`,
    {
      params: {
        roleName,
      },
    }
  );
};

/**
 * 添加角色的接口函数
 * @param roleName
 * @returns null
 */
export const addRoleApi = (roleName: string) => {
  return request.post<any, null>(Api.addRoleUrl, {
    roleName,
  });
};
